//
//  MyEverydayTaskViewController.m
//  QiYReader
//
//  Created by 奇阅科技 on 14/12/20.
//  Copyright (c) 2014年 奇阅科技. All rights reserved.
//

#import "MyEverydayTaskViewController.h"
#import "MyEverydayTaskTableViewCell.h"
#import "TaskList.h"
#import "UIViewControllerAdditions.h"
#import "Config.h"
@interface MyEverydayTaskViewController()<UITableViewDataSource,UITableViewDelegate>
{
    TaskList *taskList;
}
@property (weak, nonatomic) IBOutlet UILabel *levelLabel;
@property (weak, nonatomic) IBOutlet UILabel *currentEXPLabel;
@property (weak, nonatomic) IBOutlet UILabel *currentAllEXPLabel;
@property (weak, nonatomic) IBOutlet UILabel *nextLevelLabel;
@property (weak, nonatomic) IBOutlet UIProgressView *EXPProgressView;
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end
@implementation MyEverydayTaskViewController
-(void)viewDidLoad{
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = NO;
    [MobClick event:@"2017"];
    [self setBarBackgroundImage:@"navBackground"];
    [self setTitleForNavigation:@"每日任务"];
    [self setLeftBackButtonForNavigation];

    taskList = [TaskList currentAccount];
    [self showUserInfo];
    [[ZMYNetWorkAPI default]getNewUserInfoResponse:^(NSDictionary *resultDic) {
        [self showUserInfo];
    } error:^(NSString *errorStr) {
    }];
}
-(void)showUserInfo{
    UserAccount *user = [UserAccount currentAccount];
    if (user.experience.length>1) {
        self.levelLabel.text = [NSString stringWithFormat:@"Lv%@",user.vip_level];
        self.currentEXPLabel.text = user.experience;
        self.currentAllEXPLabel.text = [NSString stringWithFormat:@"/%@经验值",user.needs_experience];
        self.nextLevelLabel.text = [NSString stringWithFormat:@"Lv%@",[NSNumber numberWithInteger:[user.vip_level integerValue]+1]];
        self.EXPProgressView.progress = [user.experience floatValue]/[user.needs_experience floatValue];
    }
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return taskList.taskArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    MyEverydayTaskTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyEverydayTaskTableViewCell" forIndexPath:indexPath];
    cell.indexPath = indexPath;
    [cell setInformation];
    return cell;
}

@end
